package com.leetcode.LC;

public class LC1089 {
    public void duplicateZeros(int[] arr) {
        if (arr.length == 1)
            return;
        for (int i = 0; i < arr.length; ) {
            if (arr[i] == 0 && i + 1 < arr.length) {
                for (int j = arr.length - 2; j >= i + 1; j--) {
                    arr[j + 1] = arr[j];
                }
                arr[i + 1] = 0;
                i += 2;
            }else {
                i++;
            }
        }

        for (int i : arr) {
            System.out.print(i+",");
        }
    }

    public static void main(String[] args) {
        new LC1089().duplicateZeros(new int[]{0,4,1,0,0,8,0,0,3});
    }
}
